import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// vite.config.ts

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  // // 修改前端服务端口
  // server:{
  //   port:19090
  // }

  // 配置代理服务器 代理规则配置
  server: {
    proxy: {
       "/dev-api": { // 将前缀为dev-api的请求转发到target
          target: "http://127.0.0.1:19090/system", // ①http://localhost:5183/dev-api/sysUser/login   
          // ②http://127.0.0.1:19090/system/dev-api/sysUser/login 
          rewrite: (p) => p.replace(/^\/dev-api/, ""), // 将请求的dev-api替换为空字符串 
          // ③http://127.0.0.1:19090/system/sysUser/login 
      },
    },
  },
})








